package com.lz.gmall.payment.controller;

import com.alibaba.fastjson.JSON;
import com.lz.gmall.payment.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 郭运龙
 */
@RestController
@RequestMapping(value = "/api/payment")
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentService paymentService ;

    @GetMapping(value = "/alipay/submit/{orderId}")
    public String payment(@PathVariable(value = "orderId") String orderId){
        return paymentService.payment(orderId);
    }

    @PostMapping(value = "/listenpayed")
    public String listenpayed(@RequestParam Map<String, String> params) {
        log.info("获取到了支付宝支付结果数据: " + JSON.toJSONString(params));
        return paymentService.listenpayed(params);
    }
}
